<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="/2022-06-06使用Javascript制作时钟/css/index.css">
</head>

<body>
    <div class="clock">
        <div class="hour">
            <div class="hr" id="hr"></div>
        </div>
        <div class="min">
            <div class="mn" id="mn"></div>
        </div>
        <div class="sec">
            <div class="sc" id="sc"></div>
        </div>
    </div>
    <script>
        window.onload = function () {
            // 1:找到三个元素标签
            var hr = document.getElementById("hr"); //时
            var mn = document.getElementById("mn"); //分
            var sc = document.getElementById("sc"); //秒

            setInterval(function () {
                var date = new Date();
                var HH = (date.getHours() % 12);
                var MM = date.getMinutes();
                var SS = date.getSeconds();
                hr.style.transform = "rotate(" + (HH * 30) + "deg)";
                mn.style.transform = "rotate(" + (MM * 6) + "deg)";
                sc.style.transform = "rotate(" + (SS * 6) + "deg)";
            }, 1000)
        }
    </script>
</body>

</html>